var obj = {}

function defineReactive(data, key, val) {
  Object.defineProperty(data, key, {
    // 可枚举
    enumerable: true,
    // 可以被配置，比如 DELETE
    configurable: true,
    // getter
    get() {
      console.log('你试图访问obj的' + key + '属性')
      return val
    },
    // setter
    set(newValue) {
      console.log('你试图修改obj的' + key + '属性，新值为：' + newValue)
      if (val === newValue) return
      val = newValue
    },
  })
}

defineReactive(obj, 'a', 10)
defineReactive(obj, 'b', 1)
console.log(obj.a) //10
obj.a++
console.log(obj.a) //11
console.log(obj.b) //1
